#ifndef _LOGDATBASE_H_
#define _LOGDATBASE_H_

#include "stdafx.h"
#include "database.h"

class CLogDataBaseImpl :	public ILogDataBase,
							public IPlugin,
							public IPluginRun,
							public CUnknownImp
{
public:
	CLogDataBaseImpl();
	virtual ~CLogDataBaseImpl();

public:
	BEGIN_STDCOM_MAP
		STDCOM_INTERFACE_ENTRY_UNKNOWN_(ILogDataBase)
		STDCOM_INTERFACE_ENTRY(IPlugin)
		STDCOM_INTERFACE_ENTRY(IPluginRun)
		STDCOM_INTERFACE_ENTRY(ILogDataBase)
	END_STDCOM_MAP


	//IPlugin
	std_method(Init)(int Argc, basic_tchar* Argv[], IBase* pRot, IBase* pBase);
	std_method(Uninit)();
	
	//IPluginRun
	std_method(Start)(_pinstance hInstance, UINT uType);
	std_method(Stop)(UINT uExitCode);
	
	//ILogDataBase
	std_method(IsTableExist)(LPCSTR name, IBase **pTable);
	std_method(SyncTable)(LPCSTR name, IBase *pBase);
	std_method(InsertTable)(UCHAR* pBuf, ULONG uSize);

private:
	std_method(OpenErrorLogDataBase)();

	std_method(UpdateTable)(LPCSTR name,
		ITableStruct *pITableStruct);

	std_method(CreateTable)(LPCSTR name, 
		ITableStruct *pITableStruct);

	std_method(Insert)(LPCSTR name, cJSON* pRoot,
		ITableStruct *pITableStruct);

	std_method(Update)(LPCSTR name, cJSON* pRoot,
		ITableStruct *pITableStruct);

	std_method(Refresh)(LPCSTR name, cJSON* pRoot,
		ITableStruct *pITableStruct);

	std_method(GetTableFields)(Table& table,
		ITableStruct *pITableStruct);

	std_method(ExeCommand)(LPCSTR cmd);
private:
	ComRotMessagePtr	m_pRot;
	MapTableStruct		m_pMapTableStruct;
	CDatabase			m_db;


};

#endif

